package com.dofast.bt.bean;

import com.dofast.bt.base.BaseApplication;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;
import org.xutils.ex.DbException;

import java.io.Serializable;
import java.util.List;

/**
 * Created by lcf on 2016/12/6 0006.
 * 商品
 */
@Table(name = "goods")
public class GoodsBean implements Serializable {

    @Column(name = "goodsId", isId = true, property = "NOT NULL")
    private int goodsId;//商品id

    @Column(name = "name")
    private String name;//商品名称

    @Column(name = "img_head")
    private String img_head;//头像

    @Column(name = "img_content")
    private String img_content;//详情长图介绍

    @Column(name = "shopId")
    private int shopId;//店铺

    @Column(name = "content")
    private String content;//介绍

    @Column(name = "price")
    private double price;//价格

    @Column(name = "flagId")
    private int flagId;//商品标签（外连 flag表）

    @Column(name = "typeId")
    private int typeId;//类型（外联 type表）

    private String brand;//品牌
    private int num; //数量
    private boolean isCheck;// 选择
    private String articleUrl;

    public String getArticleUrl() {
        return articleUrl;
    }

    public void setArticleUrl(String articleUrl) {
        this.articleUrl = articleUrl;
    }

    public GoodsBean() {

    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public int getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(int goodsId) {
        this.goodsId = goodsId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImg_head() {
        return img_head;
    }

    public void setImg_head(String img_head) {
        this.img_head = img_head;
    }

    public String getImg_content() {
        return img_content;
    }

    public void setImg_content(String img_content) {
        this.img_content = img_content;
    }

    public int getShopId() {
        return shopId;
    }

    public void setShopId(int shopId) {
        this.shopId = shopId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getFlagId() {
        return flagId;
    }

    public void setFlagId(int flagId) {
        this.flagId = flagId;
    }

    public int getTypeId() {
        return typeId;
    }

    public void setTypeId(int typeId) {
        this.typeId = typeId;
    }

    /**
     * 获取商品轮播图列表
     *
     * @return 轮播图列表
     * @throws DbException
     */
    public List<GoodsImageBean> getGoodsImages() throws DbException {
        return BaseApplication.getDbManager().selector(GoodsImageBean.class).where("goodsId", "=", this.goodsId).findAll();
    }

    /**
     * 获取商品所属店铺信息
     *
     * @return 店铺信息
     * @throws DbException
     */
    public ShopBean getShop() throws DbException {
        return BaseApplication.getDbManager().findById(ShopBean.class, this.shopId);
    }
}
